FC=mpif90
FFLAGS=-ffree-line-length-1024 -Jmods -Imods
CPPFLAGS=-DENERGY_DIAGNOSTICS -DFORTRANUNDERSCORE -DHOMME_QUAD_PREC=0 -D_MPI=1 -DNC=4 -D_NETCDF -D_NO_OMP_THREADS=1 -DNP=4 -DPIO_INTERP -DPLEV=128 -D_PNETCDF -D_PRESTART=1 -D_PRIM -DSPHEREW=1 -DTIMING=1 -DTRILINOS=1 -D_WK_GRAD=1
VPATH=$(subst \n, :, $(shell cat Filepath))
SRCFILES=$(shell cat Srcfiles)
OBJS=$(patsubst %.f, objs/%.o, $(patsubst %.c, objs/%.o, $(patsubst %.F90, objs/%.o, $(SRCFILES))))
DIRS=objs mods movies
$(info $(shell mkdir -p $(DIRS)))
$(info $(shell ./mkSrcfiles))
$(info $(shell ./mkDepends -t objs Filepath Srcfiles > Depends))
all: preqx
preqx: $(OBJS)
	$(FC) $(OBJS) -o $@ -lpnetcdf -lnetcdf -lhdf5 -lnetcdff
objs/%.o: %.F90
	$(FC) $(CPPFLAGS) $(FFLAGS) $< -o $@ -c
objs/%.o: %.f
	$(FC) $(CPPFLAGS) $(FFLAGS) $< -o $@ -c
objs/%.o: %.c
	$(FC) $(CPPFLAGS) $< -o $@ -c
clean:
	-rm -rvf objs mods preqx Depends Srcfiles movies
clean_run:
	-rm -rvf mass.out movies
run: preqx
	./preqx < input.nl
-include Depends
